#include "main.h"

/* inspired by */
/* http://www.cs.ukzn.ac.za/~hughm/os/notes/ncurses.html#using */

int main(int argc, char **argv) {

    if (init())
        fprintf(stderr, "ERR: could not perform game initialization");

    /* create timespec struct required for nanosecond call */
    struct timespec t, t2;
    /* limit to 60 fps       */
    /* 60 fps = 1s/60f       */
    /*        = 1*10^3ms/60f */
    /*        = 1*10^9ns/60f */
    t.tv_nsec = 1000000000 / FPS;
    t.tv_sec = 0;

    int quit = 0;
    while (!quit) {
        /* process input */
        get_input(&quit);
        /* update game logic */
        update_mania();
        /* render new screen */
        render_mania();

        nanosleep(&t, &t2);
    }

    if (cleanup())
        fprintf(stderr, "ERR: could not perform post game cleanup");

    return 0;
}
